]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/include/spdk_internal/accel_engine.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / include / spdk_internal / accel_engine.h
CommitLineData
f67539c2
TL
1/*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef SPDK_INTERNAL_ACCEL_ENGINE_H
35#define SPDK_INTERNAL_ACCEL_ENGINE_H
36
37#include "spdk/stdinc.h"
38
39#include "spdk/accel_engine.h"
40#include "spdk/queue.h"
41
42struct spdk_accel_task {
43 spdk_accel_completion_cb cb;
44 void *cb_arg;
45 uint8_t offload_ctx[0];
46};
47
48struct spdk_accel_engine {
49 uint64_t (*get_capabilities)(void);
50 int (*copy)(struct spdk_io_channel *ch, void *dst, void *src,
51 uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
52 int (*dualcast)(struct spdk_io_channel *ch, void *dst1, void *dst2, void *src,
53 uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
54 uint32_t (*batch_get_max)(void);
55 struct spdk_accel_batch *(*batch_create)(struct spdk_io_channel *ch);
56 int (*batch_prep_copy)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
57 void *dst, void *src, uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
58 int (*batch_prep_dualcast)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
59 void *dst1, void *dst2, void *src, uint64_t nbytes,
60 spdk_accel_completion_cb cb_fn, void *cb_arg);
61 int (*batch_prep_compare)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
62 void *src1, void *src2, uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
63 int (*batch_prep_fill)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
64 void *dst, uint8_t fill, uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
65 int (*batch_prep_crc32c)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
66 uint32_t *dst, void *src, uint32_t seed, uint64_t nbytes,
67 spdk_accel_completion_cb cb_fn, void *cb_arg);
68 int (*batch_submit)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
69 spdk_accel_completion_cb cb_fn, void *cb_arg);
70 int (*batch_cancel)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch);
71 int (*compare)(struct spdk_io_channel *ch, void *src1, void *src2,
72 uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
73 int (*fill)(struct spdk_io_channel *ch, void *dst, uint8_t fill,
74 uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
75 int (*crc32c)(struct spdk_io_channel *ch, uint32_t *dst, void *src,
76 uint32_t seed, uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
77 struct spdk_io_channel *(*get_io_channel)(void);
78};
79
80struct spdk_accel_module_if {
81 /** Initialization function for the module. Called by the spdk
82 * application during startup.
83 *
84 * Modules are required to define this function.
85 */
86 int (*module_init)(void);
87
88 /** Finish function for the module. Called by the spdk application
89 * before the spdk application exits to perform any necessary cleanup.
90 *
91 * Modules are not required to define this function.
92 */
93 void (*module_fini)(void *ctx);
94
95 /** Function called to return a text string representing the
96 * module's configuration options for inclusion in an
97 * spdk configuration file.
98 */
99 void (*config_text)(FILE *fp);
100
101 /**
102 * Write Acceleration module configuration into provided JSON context.
103 */
104 void (*write_config_json)(struct spdk_json_write_ctx *w);
105
106 /**
107 * Returns the allocation size required for the modules to use for context.
108 */
109 size_t (*get_ctx_size)(void);
110
111 TAILQ_ENTRY(spdk_accel_module_if) tailq;
112};
113
114void spdk_accel_hw_engine_register(struct spdk_accel_engine *accel_engine);
115void spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module);
116
117#define SPDK_ACCEL_MODULE_REGISTER(init_fn, fini_fn, config_fn, config_json, ctx_size_fn) \
118 static struct spdk_accel_module_if init_fn ## _if = { \
119 .module_init = init_fn, \
120 .module_fini = fini_fn, \
121 .config_text = config_fn, \
122 .write_config_json = config_json, \
123 .get_ctx_size = ctx_size_fn, \
124 }; \
125 __attribute__((constructor)) static void init_fn ## _init(void) \
126 { \
127 spdk_accel_module_list_add(&init_fn ## _if); \
128 }
129
130#endif