Commit 78b83fd7 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Ben Walker
Browse files

copy_engine: add fill (memset) function



Change-Id: I626edcdaef8bd7a700fce5853fc2f85fc5b93ef7
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 398ba3b1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ struct copy_task {
struct spdk_copy_engine {
	int64_t	(*copy)(void *cb_arg, void *dst, void *src,
			uint64_t nbytes, copy_completion_cb cb);
	int64_t	(*fill)(void *cb_arg, void *dst, uint8_t fill,
			uint64_t nbytes, copy_completion_cb cb);
	void	(*check_io)(void);
};

@@ -84,6 +86,8 @@ struct spdk_copy_module_if {
void spdk_copy_engine_register(struct spdk_copy_engine *copy_engine);
int64_t spdk_copy_submit(struct copy_task *copy_req, void *dst, void *src,
			 uint64_t nbytes, copy_completion_cb cb);
int64_t spdk_copy_submit_fill(struct copy_task *copy_req, void *dst, uint8_t fill,
			      uint64_t nbytes, copy_completion_cb cb);
int spdk_copy_check_io(void);
int spdk_copy_module_get_max_ctx_size(void);
void spdk_copy_module_list_add(struct spdk_copy_module_if *copy_module);
+34 −0
Original line number Diff line number Diff line
@@ -113,6 +113,23 @@ spdk_copy_submit(struct copy_task *copy_req, void *dst, void *src,
				     copy_engine_done);
}

int64_t
spdk_copy_submit_fill(struct copy_task *copy_req, void *dst, uint8_t fill,
		      uint64_t nbytes, copy_completion_cb cb)
{
	struct copy_task *req = copy_req;

	req->cb = cb;

	if (hw_copy_engine && hw_copy_engine->fill) {
		return hw_copy_engine->fill(req->offload_ctx, dst, fill, nbytes,
					    copy_engine_done);
	}

	return mem_copy_engine->fill(req->offload_ctx, dst, fill, nbytes,
				     copy_engine_done);
}

/* memcpy default copy engine */
static void
mem_copy_check_io(void)
@@ -150,8 +167,25 @@ mem_copy_submit(void *cb_arg, void *dst, void *src, uint64_t nbytes,
	return nbytes;
}

static int64_t
mem_copy_fill(void *cb_arg, void *dst, uint8_t fill, uint64_t nbytes,
	      copy_completion_cb cb)
{
	struct mem_request **req_head = &copy_engine_req_head[rte_lcore_id()];
	struct mem_request *req = (struct mem_request *)cb_arg;

	req->next = *req_head;
	*req_head = req;
	req->cb = cb;

	memset(dst, fill, nbytes);

	return nbytes;
}

static struct spdk_copy_engine memcpy_copy_engine = {
	.copy		= mem_copy_submit,
	.fill		= mem_copy_fill,
	.check_io	= mem_copy_check_io,
};

+17 −0
Original line number Diff line number Diff line
@@ -142,6 +142,22 @@ ioat_copy_submit(void *cb_arg, void *dst, void *src, uint64_t nbytes,
	return spdk_ioat_submit_copy(chan, ioat_task, ioat_done, dst, src, nbytes);
}

static int64_t
ioat_copy_submit_fill(void *cb_arg, void *dst, uint8_t fill, uint64_t nbytes,
		      copy_completion_cb cb)
{
	struct ioat_task *ioat_task = (struct ioat_task *)cb_arg;
	struct spdk_ioat_chan *chan = g_ioat_chan[rte_lcore_id()];
	uint64_t fill64 = 0x0101010101010101ULL * fill;

	RTE_VERIFY(chan != NULL);

	ioat_task->cb = cb;

	return spdk_ioat_submit_fill(chan, ioat_task, ioat_done, dst, fill64, nbytes);
}


static void
ioat_check_io(void)
{
@@ -153,6 +169,7 @@ ioat_check_io(void)

static struct spdk_copy_engine ioat_copy_engine = {
	.copy		= ioat_copy_submit,
	.fill		= ioat_copy_submit_fill,
	.check_io	= ioat_check_io,
};