2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef __LAYER_EVICTION_POLICY_H__
7 #define __LAYER_EVICTION_POLICY_H__
11 #include "lru_structs.h"
12 #include "../ocf_request.h"
14 #define OCF_TO_EVICTION_MIN 128UL
15 #define OCF_PENDING_EVICTION_LIMIT 512UL
17 struct eviction_policy
{
19 struct lru_eviction_policy lru
;
23 /* Eviction policy metadata per cache line */
24 union eviction_policy_meta
{
25 struct lru_eviction_policy_meta lru
;
26 } __attribute__((packed
));
28 /* the caller must hold the metadata lock for all operations
30 * For range operations the caller can:
31 * set core_id to -1 to purge the whole cache device
32 * set core_id to -2 to purge the whole cache partition
34 struct eviction_policy_ops
{
35 void (*init_cline
)(ocf_cache_t cache
,
36 ocf_cache_line_t cline
);
37 void (*rm_cline
)(ocf_cache_t cache
,
38 ocf_cache_line_t cline
);
39 bool (*can_evict
)(ocf_cache_t cache
);
40 uint32_t (*req_clines
)(ocf_cache_t cache
,
41 ocf_queue_t io_queue
, ocf_part_id_t part_id
,
42 uint32_t cline_no
, ocf_core_id_t core_id
);
43 void (*hot_cline
)(ocf_cache_t cache
,
44 ocf_cache_line_t cline
);
45 void (*init_evp
)(ocf_cache_t cache
,
46 ocf_part_id_t part_id
);
47 void (*dirty_cline
)(ocf_cache_t cache
,
48 ocf_part_id_t part_id
,
50 void (*clean_cline
)(ocf_cache_t cache
,
51 ocf_part_id_t part_id
,
56 extern struct eviction_policy_ops evict_policy_ops
[ocf_eviction_max
];
59 * Deallocates space from low priority partitions.
62 * or the destination partition ID for the free buffers
63 * (it matches label and is part of the object (#core_id) IO group)
65 int space_managment_evict_do(ocf_cache_t cache
,
66 struct ocf_request
*req
, uint32_t evict_cline_no
);
68 int space_management_free(ocf_cache_t cache
, uint32_t count
);