]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/inc/ocf_queue.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / inc / ocf_queue.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 #ifndef OCF_QUEUE_H_
7 #define OCF_QUEUE_H_
8
9 /**
10 * @file
11 * @brief OCF queues API
12 */
13
14 /**
15 * @brief I/O queue operations
16 */
17 struct ocf_queue_ops {
18 /**
19 * @brief Kick I/O queue processing
20 *
21 * This function should inform worker, thread or any other queue
22 * processing mechanism, that there are new requests in queue to
23 * be processed. Processing requests synchronously in this function
24 * is not allowed.
25 *
26 * @param[in] q I/O queue to be kicked
27 */
28 void (*kick)(ocf_queue_t q);
29
30 /**
31 * @brief Kick I/O queue processing
32 *
33 * This function should inform worker, thread or any other queue
34 * processing mechanism, that there are new requests in queue to
35 * be processed. Function kick_sync is allowed to process requests
36 * synchronously without delegating them to the worker.
37 *
38 * @param[in] q I/O queue to be kicked
39 */
40 void (*kick_sync)(ocf_queue_t q);
41
42 /**
43 * @brief Stop I/O queue
44 *
45 * @param[in] q I/O queue beeing stopped
46 */
47 void (*stop)(ocf_queue_t q);
48 };
49
50 /**
51 * @brief Allocate IO queue and add it to list in cache
52 *
53 * @param[in] cache Handle to cache instance
54 * @param[out] queue Handle to created queue
55 * @param[in] ops Queue operations
56 *
57 * @return Zero on success, otherwise error code
58 */
59 int ocf_queue_create(ocf_cache_t cache, ocf_queue_t *queue,
60 const struct ocf_queue_ops *ops);
61
62 /**
63 * @brief Increase reference counter in queue
64 *
65 * @param[in] queue Queue
66 *
67 */
68 void ocf_queue_get(ocf_queue_t queue);
69
70 /**
71 * @brief Decrease reference counter in queue
72 *
73 * @note If queue don't have any reference - deallocate it
74 *
75 * @param[in] queue Queue
76 *
77 */
78 void ocf_queue_put(ocf_queue_t queue);
79
80 /**
81 * @brief Process single request from queue
82 *
83 * @param[in] q Queue to run
84 */
85 void ocf_queue_run_single(ocf_queue_t q);
86
87 /**
88 * @brief Run queue processing
89 *
90 * @param[in] q Queue to run
91 */
92 void ocf_queue_run(ocf_queue_t q);
93
94 /**
95 * @brief Set queue private data
96 *
97 * @param[in] q I/O queue
98 * @param[in] priv Private data
99 */
100 void ocf_queue_set_priv(ocf_queue_t q, void *priv);
101
102 /**
103 * @brief Get queue private data
104 *
105 * @param[in] q I/O queue
106 *
107 * @retval I/O queue private data
108 */
109 void *ocf_queue_get_priv(ocf_queue_t q);
110
111 /**
112 * @brief Get number of pending requests in I/O queue
113 *
114 * @param[in] q I/O queue
115 *
116 * @retval Number of pending requests in I/O queue
117 */
118 uint32_t ocf_queue_pending_io(ocf_queue_t q);
119
120 /**
121 * @brief Get cache instance to which I/O queue belongs
122 *
123 * @param[in] q I/O queue
124 *
125 * @retval Cache instance
126 */
127 ocf_cache_t ocf_queue_get_cache(ocf_queue_t q);
128
129 #endif