4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef SPDK_INTERNAL_COPY_ENGINE_H
35 #define SPDK_INTERNAL_COPY_ENGINE_H
37 #include "spdk/stdinc.h"
39 #include "spdk/copy_engine.h"
40 #include "spdk/queue.h"
42 struct spdk_copy_task
{
43 spdk_copy_completion_cb cb
;
44 uint8_t offload_ctx
[0];
47 struct spdk_copy_engine
{
48 int (*copy
)(void *cb_arg
, struct spdk_io_channel
*ch
, void *dst
, void *src
,
49 uint64_t nbytes
, spdk_copy_completion_cb cb
);
50 int (*fill
)(void *cb_arg
, struct spdk_io_channel
*ch
, void *dst
, uint8_t fill
,
51 uint64_t nbytes
, spdk_copy_completion_cb cb
);
52 struct spdk_io_channel
*(*get_io_channel
)(void);
55 struct spdk_copy_module_if
{
56 /** Initialization function for the module. Called by the spdk
57 * application during startup.
59 * Modules are required to define this function.
61 int (*module_init
)(void);
63 /** Finish function for the module. Called by the spdk application
64 * before the spdk application exits to perform any necessary cleanup.
66 * Modules are not required to define this function.
68 void (*module_fini
)(void *ctx
);
70 /** Function called to return a text string representing the
71 * module's configuration options for inclusion in an
72 * spdk configuration file.
74 void (*config_text
)(FILE *fp
);
76 size_t (*get_ctx_size
)(void);
77 TAILQ_ENTRY(spdk_copy_module_if
) tailq
;
80 void spdk_copy_engine_register(struct spdk_copy_engine
*copy_engine
);
81 void spdk_copy_module_list_add(struct spdk_copy_module_if
*copy_module
);
83 #define SPDK_COPY_MODULE_REGISTER(init_fn, fini_fn, config_fn, ctx_size_fn) \
84 static struct spdk_copy_module_if init_fn ## _if = { \
85 .module_init = init_fn, \
86 .module_fini = fini_fn, \
87 .config_text = config_fn, \
88 .get_ctx_size = ctx_size_fn, \
90 __attribute__((constructor)) static void init_fn ## _init(void) \
92 spdk_copy_module_list_add(&init_fn ## _if); \