xref: /spdk/module/bdev/ocf/ctx.h (revision 60982c759db49b4f4579f16e3b24df0725ba4b94)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2018 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 #ifndef VBDEV_OCF_CTX_H
7 #define VBDEV_OCF_CTX_H
8 
9 #include <ocf/ocf.h>
10 #include "ocf_env.h"
11 #include "spdk/thread.h"
12 
13 extern ocf_ctx_t vbdev_ocf_ctx;
14 
15 #define OCF_WRITE_FLUSH 11
16 
17 #define SPDK_OBJECT 1
18 
19 /* Context of cache instance */
20 struct vbdev_ocf_cache_ctx {
21 	ocf_queue_t                  mngt_queue;
22 	pthread_mutex_t              lock;
23 	env_atomic                   refcnt;
24 };
25 
26 void vbdev_ocf_cache_ctx_put(struct vbdev_ocf_cache_ctx *ctx);
27 void vbdev_ocf_cache_ctx_get(struct vbdev_ocf_cache_ctx *ctx);
28 
29 int vbdev_ocf_ctx_init(void);
30 void vbdev_ocf_ctx_cleanup(void);
31 
32 /* Thread safe queue creation and deletion
33  * These are wrappers for original ocf_queue_create() and ocf_queue_put() */
34 int vbdev_ocf_queue_create(ocf_cache_t cache, ocf_queue_t *queue, const struct ocf_queue_ops *ops);
35 void vbdev_ocf_queue_put(ocf_queue_t queue);
36 
37 #endif
38