summaryrefslogtreecommitdiffstats
path: root/src/spdk/ocf/inc/ocf_io_class.h
blob: caab0db027d9eb96d81e4f3e57437cb07d25cd30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Copyright(c) 2012-2018 Intel Corporation
 * SPDX-License-Identifier: BSD-3-Clause-Clear
 */

/**
 * @file
 * @brief IO class API
 *
 * File contains structures and methods for handling IO Class
 * differentiation features
 */

#ifndef __OCF_IO_CLASS_H__
#define __OCF_IO_CLASS_H__

/**
 * @brief OCF IO class information
 */
struct ocf_io_class_info {
	char name[OCF_IO_CLASS_NAME_MAX];
		/*!< The name of the IO class */

	ocf_cache_mode_t cache_mode;
		/*!< Cache mode of the IO class */

	int16_t priority;
		/*!< IO class priority */

	uint32_t curr_size;
		/*!< Current size of the IO class - number of cache lines which
		 * were assigned into this IO class
		 */

	uint32_t min_size;
		/*!< Minimum number of cache lines that were guaranteed
		 * for specified IO class. If current size reach minimum size
		 * that no more eviction takes place
		 */

	uint32_t max_size;
		/*!< Maximum number of cache lines that might be assigned into
		 * this IO class. If current size reach maximum size no more
		 * allocation for this IO class takes place
		 */

	uint8_t eviction_policy_type;
		/*!< The type of eviction policy for given IO class */

	ocf_cleaning_t cleaning_policy_type;
		/*!< The type of cleaning policy for given IO class */
};

/**
 * @brief retrieve io class info
 *
 * function meant to retrieve information pertaining to particular IO class,
 * specifically to fill ocf_io_class_info structure based on input parameters.
 *
 * @param[in] cache cache handle, to which specified request pertains.
 * @param[in] io_class id of an io class which shall be retreived.
 * @param[out] info io class info structures to be filled as a
 *             result of this function call.
 *
 * @return function returns 0 upon successful completion; appropriate error
 *         code is returned otherwise
 */
int ocf_cache_io_class_get_info(ocf_cache_t cache, uint32_t io_class,
		struct ocf_io_class_info *info);

/**
 * @brief helper function for ocf_io_class_visit
 *
 * This function is called back from ocf_io_class_visit for each valid
 * configured io class; henceforth all parameters are input parameters,
 * no exceptions. It is usable to enumerate all the io classes.
 *
 * @param[in] cache cache id of cache for which data is being retrieved
 * @param[in] io_class_id id of an io class for which callback herein
 *            is invoked.
 * @param[in] cntx a context pointer passed herein from within
 *            ocf_io_class_visit down to this callback.
 *
 * @return 0 upon success; Nonzero upon failure (when nonzero is returned,
 *         this callback won't be invoked for any more io classes)
 */
typedef int (*ocf_io_class_visitor_t)(ocf_cache_t cache,
		uint32_t io_class_id, void *cntx);

/**
 * @brief enumerate all of the available IO classes.
 *
 * This function allows enumeration and retrieval of all io class id's that
 * are valid for given cache id via visiting all those with callback function
 * that is supplied by caller.
 *
 * @param[in] cache cache id to which given call pertains
 * @param[in] visitor a callback function that will be issued for each and every
 *            IO class that is configured and valid within given cache instance
 * @param[in] cntx a context variable - structure that shall be passed to a
 *            callback function for every call
 *
 * @return 0 upon successful completion of the function; otherwise nonzero result
 *         shall be returned
 */
int ocf_io_class_visit(ocf_cache_t cache, ocf_io_class_visitor_t visitor,
		void *cntx);

#endif /* __OCF_IO_CLASS_H__ */