]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/src/utils/utils_io_allocator.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / ocf / src / utils / utils_io_allocator.h
1 /*
2 * Copyright(c) 2019 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 #ifndef __UTILS_IO_ALLOCATOR_H__
7 #define __UTILS_IO_ALLOCATOR_H__
8
9 #include "ocf/ocf_types.h"
10
11 typedef struct ocf_io_allocator *ocf_io_allocator_t;
12
13 struct ocf_io_allocator_ops {
14 int (*allocator_init)(ocf_io_allocator_t allocator,
15 uint32_t priv_size, const char *name);
16 void (*allocator_deinit)(ocf_io_allocator_t allocator);
17 void *(*allocator_new)(ocf_io_allocator_t allocator,
18 ocf_volume_t volume, ocf_queue_t queue,
19 uint64_t addr, uint32_t bytes, uint32_t dir);
20 void (*allocator_del)(ocf_io_allocator_t allocator, void *obj);
21 };
22
23 struct ocf_io_allocator_type {
24 struct ocf_io_allocator_ops ops;
25 };
26
27 typedef const struct ocf_io_allocator_type *ocf_io_allocator_type_t;
28
29 struct ocf_io_allocator {
30 const struct ocf_io_allocator_type *type;
31 void *priv;
32 };
33
34 static inline void *ocf_io_allocator_new(ocf_io_allocator_t allocator,
35 ocf_volume_t volume, ocf_queue_t queue,
36 uint64_t addr, uint32_t bytes, uint32_t dir)
37 {
38 return allocator->type->ops.allocator_new(allocator, volume, queue,
39 addr, bytes, dir);
40 }
41
42 static inline void ocf_io_allocator_del(ocf_io_allocator_t allocator, void *obj)
43 {
44 allocator->type->ops.allocator_del(allocator, obj);
45 }
46
47 static inline int ocf_io_allocator_init(ocf_io_allocator_t allocator,
48 ocf_io_allocator_type_t type, uint32_t size, const char *name)
49
50 {
51 allocator->type = type;
52 return allocator->type->ops.allocator_init(allocator, size, name);
53 }
54
55 static inline void ocf_io_allocator_deinit(ocf_io_allocator_t allocator)
56 {
57 allocator->type->ops.allocator_deinit(allocator);
58 }
59
60 ocf_io_allocator_type_t ocf_io_allocator_get_type_default(void);
61
62 #endif /* __UTILS_IO_ALLOCATOR__ */