From 25cbb9df32826622b563f3c97f3bcf77413d9b10 Mon Sep 17 00:00:00 2001 From: Alexey Marchuk Date: Thu, 14 Oct 2021 09:53:02 +0300 Subject: [PATCH] dma: Rename fetch operation to pull The new name suits better to the following "data push" operation Signed-off-by: Alexey Marchuk Change-Id: Ic3249f65de203f375477f8e87b0749b9502d165c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9878 Community-CI: Broadcom CI Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- include/spdk/dma.h | 34 +++++++-------- lib/dma/dma.c | 20 ++++----- lib/dma/spdk_dma.map | 4 +- test/unit/lib/dma/dma.c/dma_ut.c | 42 +++++++++---------- test/unit/lib/nvme/nvme_rdma.c/nvme_rdma_ut.c | 4 +- 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/include/spdk/dma.h b/include/spdk/dma.h index d08500e45..35bc68842 100644 --- a/include/spdk/dma.h +++ b/include/spdk/dma.h @@ -63,15 +63,15 @@ enum spdk_dma_device_type { struct spdk_memory_domain; /** - * Definition of completion callback to be called by fetch function. + * Definition of completion callback to be called by pull function. * - * \param ctx User context passed to fetch function - * \param rc Result of asynchronous fetch function + * \param ctx User context passed to pull function + * \param rc Result of asynchronous pull function */ -typedef void (*spdk_memory_domain_fetch_data_cpl_cb)(void *ctx, int rc); +typedef void (*spdk_memory_domain_pull_data_cpl_cb)(void *ctx, int rc); /** - * Definition of function which asynchronously fetches data from src_domain to local memory domain. + * Definition of function which asynchronously pulles data from src_domain to local memory domain. * Implementation of this function must call \b cpl_cb only when it returns 0. All other return codes mean failure. * * \param src_domain Memory domain to which the data buffer belongs @@ -81,14 +81,14 @@ typedef void (*spdk_memory_domain_fetch_data_cpl_cb)(void *ctx, int rc); * \param dst_iov Iov vector in local memory domain space, data buffers must be allocated by the caller of * this function, total size of data buffers must not be less than the size of data in \b src_iov. * \param dst_iovcnt dst_iov array size - * \param cpl_cb A callback to be called when fetch operation completes + * \param cpl_cb A callback to be called when pull operation completes * \param cpl_cb_arg Optional argument to be passed to \b cpl_cb * \return 0 on success, negated errno on failure */ -typedef int (*spdk_memory_domain_fetch_data_cb)(struct spdk_memory_domain *src_domain, +typedef int (*spdk_memory_domain_pull_data_cb)(struct spdk_memory_domain *src_domain, void *src_domain_ctx, struct iovec *src_iov, uint32_t src_iovcnt, struct iovec *dst_iov, uint32_t dst_iovcnt, - spdk_memory_domain_fetch_data_cpl_cb cpl_cb, void *cpl_cb_arg); + spdk_memory_domain_pull_data_cpl_cb cpl_cb, void *cpl_cb_arg); struct spdk_memory_domain_translation_result { /** size of this structure in bytes */ @@ -173,13 +173,13 @@ void spdk_memory_domain_set_translation(struct spdk_memory_domain *domain, spdk_memory_domain_translate_memory_cb translate_cb); /** - * Set fetch function for memory domain. Overwrites existing fetch function. + * Set pull function for memory domain. Overwrites existing pull function. * * \param domain Memory domain - * \param fetch_cb Fetch function + * \param pull_cb pull function */ -void spdk_memory_domain_set_fetch(struct spdk_memory_domain *domain, - spdk_memory_domain_fetch_data_cb fetch_cb); +void spdk_memory_domain_set_pull(struct spdk_memory_domain *domain, + spdk_memory_domain_pull_data_cb pull_cb); /** * Get the context passed by the user in \ref spdk_memory_domain_create @@ -212,7 +212,7 @@ const char *spdk_memory_domain_get_dma_device_id(struct spdk_memory_domain *doma void spdk_memory_domain_destroy(struct spdk_memory_domain *domain); /** - * Asynchronously fetch data which is described by \b src_domain and located in \b src_iov to a location + * Asynchronously pull data which is described by \b src_domain and located in \b src_iov to a location * \b dst_iov local memory space. * * \param src_domain Memory domain in which space data buffer is located @@ -223,12 +223,12 @@ void spdk_memory_domain_destroy(struct spdk_memory_domain *domain); * \param dst_iov_cnt The number of elements in \b dst_iov * \param cpl_cb Completion callback * \param cpl_cb_arg Completion callback argument - * \return 0 on success, negated errno on failure. fetch_cb implementation must only call the callback when 0 + * \return 0 on success, negated errno on failure. pull_cb implementation must only call the callback when 0 * is returned */ -int spdk_memory_domain_fetch_data(struct spdk_memory_domain *src_domain, void *src_domain_ctx, - struct iovec *src_iov, uint32_t src_iov_cnt, struct iovec *dst_iov, uint32_t dst_iov_cnt, - spdk_memory_domain_fetch_data_cpl_cb cpl_cb, void *cpl_cb_arg); +int spdk_memory_domain_pull_data(struct spdk_memory_domain *src_domain, void *src_domain_ctx, + struct iovec *src_iov, uint32_t src_iov_cnt, struct iovec *dst_iov, uint32_t dst_iov_cnt, + spdk_memory_domain_pull_data_cpl_cb cpl_cb, void *cpl_cb_arg); /** * Translate data located in \b src_domain space at address \b addr with size \b len into an equivalent diff --git a/lib/dma/dma.c b/lib/dma/dma.c index 8d21b8ceb..02d3ac4d0 100644 --- a/lib/dma/dma.c +++ b/lib/dma/dma.c @@ -41,7 +41,7 @@ TAILQ_HEAD(, spdk_memory_domain) g_dma_memory_domains = TAILQ_HEAD_INITIALIZER( struct spdk_memory_domain { enum spdk_dma_device_type type; - spdk_memory_domain_fetch_data_cb fetch_cb; + spdk_memory_domain_pull_data_cb pull_cb; spdk_memory_domain_translate_memory_cb translate_cb; TAILQ_ENTRY(spdk_memory_domain) link; struct spdk_memory_domain_ctx *ctx; @@ -116,14 +116,14 @@ spdk_memory_domain_set_translation(struct spdk_memory_domain *domain, } void -spdk_memory_domain_set_fetch(struct spdk_memory_domain *domain, - spdk_memory_domain_fetch_data_cb fetch_cb) +spdk_memory_domain_set_pull(struct spdk_memory_domain *domain, + spdk_memory_domain_pull_data_cb pull_cb) { if (!domain) { return; } - domain->fetch_cb = fetch_cb; + domain->pull_cb = pull_cb; } struct spdk_memory_domain_ctx * @@ -166,20 +166,20 @@ spdk_memory_domain_destroy(struct spdk_memory_domain *domain) } int -spdk_memory_domain_fetch_data(struct spdk_memory_domain *src_domain, void *src_domain_ctx, - struct iovec *src_iov, uint32_t src_iov_cnt, struct iovec *dst_iov, uint32_t dst_iov_cnt, - spdk_memory_domain_fetch_data_cpl_cb cpl_cb, void *cpl_cb_arg) +spdk_memory_domain_pull_data(struct spdk_memory_domain *src_domain, void *src_domain_ctx, + struct iovec *src_iov, uint32_t src_iov_cnt, struct iovec *dst_iov, uint32_t dst_iov_cnt, + spdk_memory_domain_pull_data_cpl_cb cpl_cb, void *cpl_cb_arg) { assert(src_domain); assert(src_iov); assert(dst_iov); - if (spdk_unlikely(!src_domain->fetch_cb)) { + if (spdk_unlikely(!src_domain->pull_cb)) { return -ENOTSUP; } - return src_domain->fetch_cb(src_domain, src_domain_ctx, src_iov, src_iov_cnt, dst_iov, dst_iov_cnt, - cpl_cb, cpl_cb_arg); + return src_domain->pull_cb(src_domain, src_domain_ctx, src_iov, src_iov_cnt, dst_iov, dst_iov_cnt, + cpl_cb, cpl_cb_arg); } int diff --git a/lib/dma/spdk_dma.map b/lib/dma/spdk_dma.map index 2edc9fced..aeef0a32f 100644 --- a/lib/dma/spdk_dma.map +++ b/lib/dma/spdk_dma.map @@ -4,12 +4,12 @@ # public functions spdk_memory_domain_create; spdk_memory_domain_set_translation; - spdk_memory_domain_set_fetch; + spdk_memory_domain_set_pull; spdk_memory_domain_get_context; spdk_memory_domain_get_dma_device_type; spdk_memory_domain_get_dma_device_id; spdk_memory_domain_destroy; - spdk_memory_domain_fetch_data; + spdk_memory_domain_pull_data; spdk_memory_domain_translate_data; spdk_memory_domain_get_first; spdk_memory_domain_get_next; diff --git a/test/unit/lib/dma/dma.c/dma_ut.c b/test/unit/lib/dma/dma.c/dma_ut.c index 0bd446373..284cd4b69 100644 --- a/test/unit/lib/dma/dma.c/dma_ut.c +++ b/test/unit/lib/dma/dma.c/dma_ut.c @@ -36,20 +36,20 @@ #include "unit/lib/json_mock.c" #include "dma/dma.c" -static bool g_memory_domain_fetch_called; +static bool g_memory_domain_pull_called; static bool g_memory_domain_translate_called; static int g_memory_domain_cb_rc = 123; static void -test_memory_domain_fetch_data_cpl_cb(void *ctx, int rc) +test_memory_domain_pull_data_cpl_cb(void *ctx, int rc) { } -static int test_memory_domain_fetch_data_cb(struct spdk_memory_domain *src_device, +static int test_memory_domain_pull_data_cb(struct spdk_memory_domain *src_device, void *src_device_ctx, struct iovec *src_iov, uint32_t src_iovcnt, struct iovec *dst_iov, - uint32_t dst_iovcnt, spdk_memory_domain_fetch_data_cpl_cb cpl_cb, void *cpl_cb_arg) + uint32_t dst_iovcnt, spdk_memory_domain_pull_data_cpl_cb cpl_cb, void *cpl_cb_arg) { - g_memory_domain_fetch_called = true; + g_memory_domain_pull_called = true; return g_memory_domain_cb_rc; } @@ -105,21 +105,21 @@ test_dma(void) id = spdk_memory_domain_get_dma_device_id(domain); CU_ASSERT((!strcmp(id, domain->id))); - /* Fetch data, callback is NULL. Expect fail */ - g_memory_domain_fetch_called = false; - rc = spdk_memory_domain_fetch_data(domain, NULL, &src_iov, 1, &dst_iov, 1, - test_memory_domain_fetch_data_cpl_cb, NULL); + /* pull data, callback is NULL. Expect fail */ + g_memory_domain_pull_called = false; + rc = spdk_memory_domain_pull_data(domain, NULL, &src_iov, 1, &dst_iov, 1, + test_memory_domain_pull_data_cpl_cb, NULL); CU_ASSERT(rc == -ENOTSUP); - CU_ASSERT(g_memory_domain_fetch_called == false); + CU_ASSERT(g_memory_domain_pull_called == false); - /* Set fetch callback */ - spdk_memory_domain_set_fetch(domain, test_memory_domain_fetch_data_cb); + /* Set pull callback */ + spdk_memory_domain_set_pull(domain, test_memory_domain_pull_data_cb); - /* Fetch data. Expect pass */ - rc = spdk_memory_domain_fetch_data(domain, NULL, &src_iov, 1, &dst_iov, 1, - test_memory_domain_fetch_data_cpl_cb, NULL); + /* pull data. Expect pass */ + rc = spdk_memory_domain_pull_data(domain, NULL, &src_iov, 1, &dst_iov, 1, + test_memory_domain_pull_data_cpl_cb, NULL); CU_ASSERT(rc == g_memory_domain_cb_rc); - CU_ASSERT(g_memory_domain_fetch_called == true); + CU_ASSERT(g_memory_domain_pull_called == true); /* Translate data, callback is NULL. Expect fail */ g_memory_domain_translate_called = false; @@ -146,13 +146,13 @@ test_dma(void) spdk_memory_domain_set_translation(domain, test_memory_domain_translate_memory_cb); CU_ASSERT(domain->translate_cb == test_memory_domain_translate_memory_cb); - /* Set fetch callback to NULL. Expect pass */ - spdk_memory_domain_set_fetch(domain, NULL); - CU_ASSERT(domain->fetch_cb == NULL); + /* Set pull callback to NULL. Expect pass */ + spdk_memory_domain_set_pull(domain, NULL); + CU_ASSERT(domain->pull_cb == NULL); /* Set translation_callback. Expect pass */ - spdk_memory_domain_set_fetch(domain, test_memory_domain_fetch_data_cb); - CU_ASSERT(domain->fetch_cb == test_memory_domain_fetch_data_cb); + spdk_memory_domain_set_pull(domain, test_memory_domain_pull_data_cb); + CU_ASSERT(domain->pull_cb == test_memory_domain_pull_data_cb); /* Create 2nd and 3rd memory domains with equal id to test enumeration */ rc = spdk_memory_domain_create(&domain_2, SPDK_DMA_DEVICE_TYPE_RDMA, &memory_domain_ctx, "test_2"); diff --git a/test/unit/lib/nvme/nvme_rdma.c/nvme_rdma_ut.c b/test/unit/lib/nvme/nvme_rdma.c/nvme_rdma_ut.c index 7499d5bb2..22437b15e 100644 --- a/test/unit/lib/nvme/nvme_rdma.c/nvme_rdma_ut.c +++ b/test/unit/lib/nvme/nvme_rdma.c/nvme_rdma_ut.c @@ -67,9 +67,9 @@ DEFINE_STUB(spdk_memory_domain_get_context, struct spdk_memory_domain_ctx *, DEFINE_STUB(spdk_memory_domain_get_dma_device_type, enum spdk_dma_device_type, (struct spdk_memory_domain *device), SPDK_DMA_DEVICE_TYPE_RDMA); DEFINE_STUB_V(spdk_memory_domain_destroy, (struct spdk_memory_domain *device)); -DEFINE_STUB(spdk_memory_domain_fetch_data, int, (struct spdk_memory_domain *src_domain, +DEFINE_STUB(spdk_memory_domain_pull_data, int, (struct spdk_memory_domain *src_domain, void *src_domain_ctx, struct iovec *src_iov, uint32_t src_iov_cnt, struct iovec *dst_iov, - uint32_t dst_iov_cnt, spdk_memory_domain_fetch_data_cpl_cb cpl_cb, void *cpl_cb_arg), 0); + uint32_t dst_iov_cnt, spdk_memory_domain_pull_data_cpl_cb cpl_cb, void *cpl_cb_arg), 0); DEFINE_RETURN_MOCK(spdk_memory_domain_create, int); int