]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/src/engine/cache_engine.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / src / engine / cache_engine.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 #ifndef __CACHE_ENGINE_H_
7 #define __CACHE_ENGINE_H_
8
9 struct ocf_thread_priv;
10 struct ocf_request;
11
12 #define LOOKUP_HIT 5
13 #define LOOKUP_MISS 6
14 #define LOOKUP_MAPPED 8
15
16 typedef enum {
17 /* modes inherited from user API */
18 ocf_req_cache_mode_wt = ocf_cache_mode_wt,
19 ocf_req_cache_mode_wb = ocf_cache_mode_wb,
20 ocf_req_cache_mode_wa = ocf_cache_mode_wa,
21 ocf_req_cache_mode_pt = ocf_cache_mode_pt,
22 ocf_req_cache_mode_wi = ocf_cache_mode_wi,
23
24 /* internal modes */
25 ocf_req_cache_mode_fast,
26 /*!< Fast path */
27 ocf_req_cache_mode_d2c,
28 /*!< Direct to Core - pass through to core without
29 touching cacheline metadata */
30
31 ocf_req_cache_mode_max,
32 } ocf_req_cache_mode_t;
33
34 struct ocf_io_if {
35 int (*read)(struct ocf_request *req);
36
37 int (*write)(struct ocf_request *req);
38
39 const char *name;
40 };
41
42 ocf_cache_mode_t ocf_get_effective_cache_mode(ocf_cache_t cache,
43 ocf_core_t core, struct ocf_io *io);
44
45 const struct ocf_io_if *ocf_get_io_if(ocf_req_cache_mode_t cache_mode);
46
47 static inline const char *ocf_get_io_iface_name(ocf_cache_mode_t cache_mode)
48 {
49 const struct ocf_io_if *iface = ocf_get_io_if(cache_mode);
50
51 return iface ? iface->name : "Unknown";
52 }
53
54 static inline bool ocf_cache_mode_is_valid(ocf_cache_mode_t mode)
55 {
56 return mode >= ocf_cache_mode_wt && mode < ocf_cache_mode_max;
57 }
58
59 void ocf_seq_cutoff_update(ocf_core_t core, struct ocf_request *req);
60
61 bool ocf_fallback_pt_is_on(ocf_cache_t cache);
62
63 bool ocf_seq_cutoff_check(ocf_core_t core, uint32_t dir, uint64_t addr,
64 uint64_t bytes);
65
66 struct ocf_request *ocf_engine_pop_req(struct ocf_cache *cache,
67 struct ocf_queue *q);
68
69 int ocf_engine_hndl_req(struct ocf_request *req,
70 ocf_req_cache_mode_t req_cache_mode);
71
72 #define OCF_FAST_PATH_YES 7
73 #define OCF_FAST_PATH_NO 13
74
75 int ocf_engine_hndl_fast_req(struct ocf_request *req,
76 ocf_req_cache_mode_t req_cache_mode);
77
78 void ocf_engine_hndl_discard_req(struct ocf_request *req);
79
80 void ocf_engine_hndl_ops_req(struct ocf_request *req);
81
82 #endif