]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/inc/ocf_io_class.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / inc / ocf_io_class.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 /**
7 * @file
8 * @brief IO class API
9 *
10 * File contains structures and methods for handling IO Class
11 * differentiation features
12 */
13
14 #ifndef __OCF_IO_CLASS_H__
15 #define __OCF_IO_CLASS_H__
16
17 /**
18 * @brief OCF IO class information
19 */
20 struct ocf_io_class_info {
21 char name[OCF_IO_CLASS_NAME_MAX];
22 /*!< The name of the IO class */
23
24 ocf_cache_mode_t cache_mode;
25 /*!< Cache mode of the IO class */
26
27 int16_t priority;
28 /*!< IO class priority */
29
30 uint32_t curr_size;
31 /*!< Current size of the IO class - number of cache lines which
32 * were assigned into this IO class
33 */
34
35 uint32_t min_size;
36 /*!< Minimum number of cache lines that were guaranteed
37 * for specified IO class. If current size reach minimum size
38 * that no more eviction takes place
39 */
40
41 uint32_t max_size;
42 /*!< Maximum number of cache lines that might be assigned into
43 * this IO class. If current size reach maximum size no more
44 * allocation for this IO class takes place
45 */
46
47 uint8_t eviction_policy_type;
48 /*!< The type of eviction policy for given IO class */
49
50 ocf_cleaning_t cleaning_policy_type;
51 /*!< The type of cleaning policy for given IO class */
52 };
53
54 /**
55 * @brief retrieve io class info
56 *
57 * function meant to retrieve information pertaining to particular IO class,
58 * specifically to fill ocf_io_class_info structure based on input parameters.
59 *
60 * @param[in] cache cache handle, to which specified request pertains.
61 * @param[in] io_class id of an io class which shall be retreived.
62 * @param[out] info io class info structures to be filled as a
63 * result of this function call.
64 *
65 * @return function returns 0 upon successful completion; appropriate error
66 * code is returned otherwise
67 */
68 int ocf_cache_io_class_get_info(ocf_cache_t cache, uint32_t io_class,
69 struct ocf_io_class_info *info);
70
71 /**
72 * @brief helper function for ocf_io_class_visit
73 *
74 * This function is called back from ocf_io_class_visit for each valid
75 * configured io class; henceforth all parameters are input parameters,
76 * no exceptions. It is usable to enumerate all the io classes.
77 *
78 * @param[in] cache cache id of cache for which data is being retrieved
79 * @param[in] io_class_id id of an io class for which callback herein
80 * is invoked.
81 * @param[in] cntx a context pointer passed herein from within
82 * ocf_io_class_visit down to this callback.
83 *
84 * @return 0 upon success; Nonzero upon failure (when nonzero is returned,
85 * this callback won't be invoked for any more io classes)
86 */
87 typedef int (*ocf_io_class_visitor_t)(ocf_cache_t cache,
88 uint32_t io_class_id, void *cntx);
89
90 /**
91 * @brief enumerate all of the available IO classes.
92 *
93 * This function allows enumeration and retrieval of all io class id's that
94 * are valid for given cache id via visiting all those with callback function
95 * that is supplied by caller.
96 *
97 * @param[in] cache cache id to which given call pertains
98 * @param[in] visitor a callback function that will be issued for each and every
99 * IO class that is configured and valid within given cache instance
100 * @param[in] cntx a context variable - structure that shall be passed to a
101 * callback function for every call
102 *
103 * @return 0 upon successful completion of the function; otherwise nonzero result
104 * shall be returned
105 */
106 int ocf_io_class_visit(ocf_cache_t cache, ocf_io_class_visitor_t visitor,
107 void *cntx);
108
109 #endif /* __OCF_IO_CLASS_H__ */