Commit 293f5ea8 authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

dma: add support for invalidate data



This operation is optional and is meant to be executed on
the translation result.

Change-Id: Ib0568310180e3443f56bba847226d40a370805f7
Signed-off-by: default avatarBen Walker <ben@nvidia.com>
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21911


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 avatarJim Harris <jim.harris@samsung.com>
parent f914cd2e
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -154,6 +154,17 @@ typedef int (*spdk_memory_domain_translate_memory_cb)(struct spdk_memory_domain
		struct spdk_memory_domain_translation_ctx *dst_domain_ctx, void *addr, size_t len,
		struct spdk_memory_domain_translation_result *result);

/**
 * Definition of function which invalidates the data range in the given domain
 *
 * \param domain Memory domain to which the data buffer belongs
 * \param domain_ctx Optional context passed by upper layer
 * \param iov Iov array in \b domain memory space to be invalidated
 * \param iovcnt Iov array size
 */
typedef void (*spdk_memory_domain_invalidate_data_cb)(struct spdk_memory_domain *domain,
		void *domain_ctx, struct iovec *iov, uint32_t iovcnt);

/** Context of memory domain of RDMA type */
struct spdk_memory_domain_rdma_ctx {
	/** size of this structure in bytes */
@@ -198,6 +209,15 @@ int spdk_memory_domain_create(struct spdk_memory_domain **domain, enum spdk_dma_
void spdk_memory_domain_set_translation(struct spdk_memory_domain *domain,
					spdk_memory_domain_translate_memory_cb translate_cb);

/**
 * Set invalidate function for memory domain. Overwrites existing invalidate function.
 *
 * @param domain Memory domain
 * @param invalidate_cb Invalidate function
 */
void spdk_memory_domain_set_invalidate(struct spdk_memory_domain *domain,
				       spdk_memory_domain_invalidate_data_cb invalidate_cb);

/**
 * Set pull function for memory domain. Overwrites existing pull function.
 *
@@ -316,6 +336,21 @@ int spdk_memory_domain_translate_data(struct spdk_memory_domain *src_domain, voi
				      struct spdk_memory_domain *dst_domain, struct spdk_memory_domain_translation_ctx *dst_domain_ctx,
				      void *addr, size_t len, struct spdk_memory_domain_translation_result *result);

/**
 * Invalidate memory in the given domain.
 *
 * This function calls \b domain invalidate callback, the callback needs to be set using \ref
 * spdk_memory_domain_set_invalidate function.
 * This operation is optional and is meant to be executed on the translation result \ref spdk_memory_domain_translate_data.
 *
 * \param domain Memory domain in which address space of the buffer is located
 * \param domain_ctx User defined context
 * \param iov Iov vector in \b domain memory space to be invalidated
 * \param iovcnt iov array size
 */
void spdk_memory_domain_invalidate_data(struct spdk_memory_domain *domain, void *domain_ctx,
					struct iovec *iov, uint32_t iovcnt);

/**
 * Fills memory in \b domain with zeroes
 *
+23 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ struct spdk_memory_domain {
	spdk_memory_domain_pull_data_cb pull_cb;
	spdk_memory_domain_push_data_cb push_cb;
	spdk_memory_domain_translate_memory_cb translate_cb;
	spdk_memory_domain_invalidate_data_cb invalidate_cb;
	spdk_memory_domain_memzero_cb memzero_cb;
	TAILQ_ENTRY(spdk_memory_domain) link;
	struct spdk_memory_domain_ctx *ctx;
@@ -107,6 +108,15 @@ spdk_memory_domain_set_translation(struct spdk_memory_domain *domain,
	domain->translate_cb = translate_cb;
}

void
spdk_memory_domain_set_invalidate(struct spdk_memory_domain *domain,
				  spdk_memory_domain_invalidate_data_cb invalidate_cb)
{
	assert(domain);

	domain->invalidate_cb = invalidate_cb;
}

void
spdk_memory_domain_set_pull(struct spdk_memory_domain *domain,
			    spdk_memory_domain_pull_data_cb pull_cb)
@@ -236,6 +246,19 @@ spdk_memory_domain_translate_data(struct spdk_memory_domain *src_domain, void *s
					result);
}

void
spdk_memory_domain_invalidate_data(struct spdk_memory_domain *domain, void *domain_ctx,
				   struct iovec *iov, uint32_t iovcnt)
{
	assert(domain);

	if (spdk_unlikely(!domain->invalidate_cb)) {
		return;
	}

	domain->invalidate_cb(domain, domain_ctx, iov, iovcnt);
}

int
spdk_memory_domain_memzero(struct spdk_memory_domain *domain, void *domain_ctx, struct iovec *iov,
			   uint32_t iovcnt, spdk_memory_domain_data_cpl_cb cpl_cb, void *cpl_cb_arg)
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
	# public functions
	spdk_memory_domain_create;
	spdk_memory_domain_set_translation;
	spdk_memory_domain_set_invalidate;
	spdk_memory_domain_set_pull;
	spdk_memory_domain_set_push;
	spdk_memory_domain_set_memzero;
@@ -14,6 +15,7 @@
	spdk_memory_domain_pull_data;
	spdk_memory_domain_push_data;
	spdk_memory_domain_translate_data;
	spdk_memory_domain_invalidate_data;
	spdk_memory_domain_memzero;
	spdk_memory_domain_get_first;
	spdk_memory_domain_get_next;