2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2020 Intel Corporation.
|
2016-11-16 21:20:30 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
#ifndef SPDK_ACCEL_MODULE_H
|
|
|
|
#define SPDK_ACCEL_MODULE_H
|
2016-11-16 21:20:30 +00:00
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-11-16 21:20:30 +00:00
|
|
|
|
2022-08-08 20:31:08 +00:00
|
|
|
#include "spdk/accel.h"
|
2016-11-16 21:20:30 +00:00
|
|
|
#include "spdk/queue.h"
|
2022-04-19 22:09:18 +00:00
|
|
|
#include "spdk/config.h"
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
struct spdk_accel_task;
|
|
|
|
|
|
|
|
void spdk_accel_task_complete(struct spdk_accel_task *task, int status);
|
|
|
|
|
|
|
|
struct spdk_accel_task {
|
2021-11-17 18:48:24 +00:00
|
|
|
struct accel_io_channel *accel_ch;
|
|
|
|
spdk_accel_completion_cb cb_fn;
|
|
|
|
void *cb_arg;
|
2020-12-21 12:17:06 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2021-10-12 22:32:49 +00:00
|
|
|
struct iovec *iovs; /* iovs passed by the caller */
|
|
|
|
uint32_t iovcnt; /* iovcnt passed by the caller */
|
2022-07-21 21:57:11 +00:00
|
|
|
} s;
|
2020-12-21 12:17:06 +00:00
|
|
|
void *src;
|
|
|
|
};
|
2020-07-28 17:51:20 +00:00
|
|
|
union {
|
2022-09-22 19:01:56 +00:00
|
|
|
struct {
|
|
|
|
struct iovec *iovs; /* iovs passed by the caller */
|
|
|
|
uint32_t iovcnt; /* iovcnt passed by the caller */
|
|
|
|
} d;
|
2020-07-28 17:51:20 +00:00
|
|
|
void *dst;
|
|
|
|
void *src2;
|
|
|
|
};
|
2020-12-21 12:17:06 +00:00
|
|
|
union {
|
|
|
|
void *dst2;
|
|
|
|
uint32_t seed;
|
|
|
|
uint64_t fill_pattern;
|
|
|
|
};
|
2022-05-20 19:08:38 +00:00
|
|
|
union {
|
|
|
|
uint32_t *crc_dst;
|
|
|
|
uint32_t *output_size;
|
|
|
|
};
|
2020-07-28 17:51:20 +00:00
|
|
|
enum accel_opcode op_code;
|
|
|
|
uint64_t nbytes;
|
2022-05-20 19:08:38 +00:00
|
|
|
uint64_t nbytes_dst;
|
2021-08-24 21:08:29 +00:00
|
|
|
int flags;
|
2021-08-13 06:12:47 +00:00
|
|
|
int status;
|
2020-08-11 18:17:14 +00:00
|
|
|
TAILQ_ENTRY(spdk_accel_task) link;
|
2016-11-16 21:20:30 +00:00
|
|
|
};
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
struct spdk_accel_module_if {
|
2016-11-16 21:20:30 +00:00
|
|
|
/** Initialization function for the module. Called by the spdk
|
|
|
|
* application during startup.
|
|
|
|
*
|
|
|
|
* Modules are required to define this function.
|
|
|
|
*/
|
|
|
|
int (*module_init)(void);
|
|
|
|
|
|
|
|
/** Finish function for the module. Called by the spdk application
|
|
|
|
* before the spdk application exits to perform any necessary cleanup.
|
|
|
|
*
|
|
|
|
* Modules are not required to define this function.
|
|
|
|
*/
|
2017-10-25 13:58:02 +00:00
|
|
|
void (*module_fini)(void *ctx);
|
2016-11-16 21:20:30 +00:00
|
|
|
|
2020-04-27 15:45:46 +00:00
|
|
|
/**
|
|
|
|
* Write Acceleration module configuration into provided JSON context.
|
|
|
|
*/
|
|
|
|
void (*write_config_json)(struct spdk_json_write_ctx *w);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the allocation size required for the modules to use for context.
|
|
|
|
*/
|
2016-11-16 21:23:57 +00:00
|
|
|
size_t (*get_ctx_size)(void);
|
2020-04-27 15:45:46 +00:00
|
|
|
|
2022-08-05 19:25:33 +00:00
|
|
|
const char *name;
|
|
|
|
bool (*supports_opcode)(enum accel_opcode);
|
|
|
|
struct spdk_io_channel *(*get_io_channel)(void);
|
|
|
|
int (*submit_tasks)(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task);
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
TAILQ_ENTRY(spdk_accel_module_if) tailq;
|
2016-11-16 21:20:30 +00:00
|
|
|
};
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
void spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module);
|
2016-11-16 21:20:30 +00:00
|
|
|
|
2022-08-05 19:01:47 +00:00
|
|
|
#define SPDK_ACCEL_MODULE_REGISTER(name, module) \
|
|
|
|
static void __attribute__((constructor)) _spdk_accel_module_register_##name(void) \
|
|
|
|
{ \
|
|
|
|
spdk_accel_module_list_add(module); \
|
|
|
|
}
|
2016-11-16 21:20:30 +00:00
|
|
|
|
2022-08-08 20:36:34 +00:00
|
|
|
/**
|
|
|
|
* Called by an accel module when cleanup initiated during .module_fini has completed
|
|
|
|
*/
|
|
|
|
void spdk_accel_module_finish(void);
|
|
|
|
|
2016-11-16 21:20:30 +00:00
|
|
|
#endif
|