Commit 9933475b authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

nvme: add accel sequence callbacks



These callbacks will allow the NVMe driver to use the new accel sequence
API and chain operations scheduled by the driver with a sequence
prepared by the user.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I7d252bb90271429babf1bca1ccb54d5b071072df
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18761


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 60982c75
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
extern "C" {
#endif

#include "spdk/dma.h"
#include "spdk/env.h"
#include "spdk/nvme_spec.h"
#include "spdk/nvmf_spec.h"
@@ -295,6 +296,13 @@ SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ctrlr_opts) == 824, "Incorrect size")
 */
typedef void (*spdk_nvme_accel_completion_cb)(void *cb_arg, int status);

/**
 * Completion callback for a single operation in a sequence.
 *
 * \param cb_arg Argument provided by the user when appending an operation to a sequence.
 */
typedef void (*spdk_nvme_accel_step_cb)(void *cb_arg);

/**
 * Function table for the NVMe accelerator device.
 *
@@ -314,6 +322,20 @@ struct spdk_nvme_accel_fn_table {
	/** The accelerated crc32c function. */
	void (*submit_accel_crc32c)(void *ctx, uint32_t *dst, struct iovec *iov,
				    uint32_t iov_cnt, uint32_t seed, spdk_nvme_accel_completion_cb cb_fn, void *cb_arg);

	/** Finish an accel sequence */
	void (*finish_sequence)(void *seq, spdk_nvme_accel_completion_cb cb_fn, void *cb_arg);

	/** Reverse an accel sequence */
	void (*reverse_sequence)(void *seq);

	/** Abort an accel sequence */
	void (*abort_sequence)(void *seq);

	/** Append a crc32c operation to a sequence */
	int (*append_crc32c)(void *ctx, void **seq, uint32_t *dst, struct iovec *iovs, uint32_t iovcnt,
			     struct spdk_memory_domain *memory_domain, void *domain_ctx,
			     uint32_t seed, spdk_nvme_accel_step_cb cb_fn, void *cb_arg);
};

/**
+24 −1
Original line number Diff line number Diff line
@@ -25,13 +25,36 @@ spdk_nvme_poll_group_create(void *ctx, struct spdk_nvme_accel_fn_table *table)
	} \

		SET_FIELD(submit_accel_crc32c);
		SET_FIELD(append_crc32c);
		SET_FIELD(finish_sequence);
		SET_FIELD(reverse_sequence);
		SET_FIELD(abort_sequence);
		/* Do not remove this statement, you should always update this statement when you adding a new field,
		 * and do not forget to add the SET_FIELD statement for your added field. */
		SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_accel_fn_table) == 16, "Incorrect size");
		SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_accel_fn_table) == 48, "Incorrect size");

#undef SET_FIELD
	}

	/* Make sure either all or none of the sequence manipulation callbacks are implemented */
	if ((group->accel_fn_table.finish_sequence && group->accel_fn_table.reverse_sequence &&
	     group->accel_fn_table.abort_sequence) !=
	    (group->accel_fn_table.finish_sequence || group->accel_fn_table.reverse_sequence ||
	     group->accel_fn_table.abort_sequence)) {
		SPDK_ERRLOG("Invalid accel_fn_table configuration: either all or none of the "
			    "sequence callbacks must be provided\n");
		free(group);
		return NULL;
	}

	/* Make sure that sequence callbacks are implemented if append* callbacks are provided */
	if (group->accel_fn_table.append_crc32c && !group->accel_fn_table.finish_sequence) {
		SPDK_ERRLOG("Invalid accel_fn_table configuration: append_crc32c requires sequence "
			    "callbacks to be provided\n");
		free(group);
		return NULL;
	}

	group->ctx = ctx;
	STAILQ_INIT(&group->tgroups);