From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, stephen@networkplumber.org
Subject: [dpdk-dev] [PATCH v2 1/4] test/extmem: refactor and rename test functions
Date: Fri, 21 Dec 2018 11:29:00 +0000 [thread overview]
Message-ID: <c822e5e21620d0fa4b2930d9e89bce44e80eac73.1545391716.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <c822e5e21620d0fa4b2930d9e89bce44e80eac73.1545390524.git.anatoly.burakov@intel.com>
We will be adding a new extmem test that will behave roughly similar
to already existing, so clarify function names to distinguish between
these tests, as well as factor out the common parts.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
test/test/test_external_mem.c | 62 +++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/test/test/test_external_mem.c b/test/test/test_external_mem.c
index 998cafa68..6df42e3ae 100644
--- a/test/test/test_external_mem.c
+++ b/test/test/test_external_mem.c
@@ -23,7 +23,35 @@
#define EXTERNAL_MEM_SZ (RTE_PGSIZE_4K << 10) /* 4M of data */
static int
-test_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
+check_mem(void *addr, rte_iova_t *iova, size_t pgsz, int n_pages)
+{
+ int i;
+
+ /* check that we can get this memory from EAL now */
+ for (i = 0; i < n_pages; i++) {
+ const struct rte_memseg *ms;
+ void *cur = RTE_PTR_ADD(addr, pgsz * i);
+
+ ms = rte_mem_virt2memseg(cur, NULL);
+ if (ms == NULL) {
+ printf("%s():%i: Failed to retrieve memseg for external mem\n",
+ __func__, __LINE__);
+ return -1;
+ }
+ if (ms->addr != cur) {
+ printf("%s():%i: VA mismatch\n", __func__, __LINE__);
+ return -1;
+ }
+ if (ms->iova != iova[i]) {
+ printf("%s():%i: IOVA mismatch\n", __func__, __LINE__);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int
+test_malloc_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
int n_pages)
{
static const char * const names[] = {
@@ -223,11 +251,12 @@ test_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
}
static int
-test_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova, int n_pages)
+test_malloc_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
+ int n_pages)
{
const char *heap_name = "heap";
void *ptr = NULL;
- int socket_id, i;
+ int socket_id;
const struct rte_memzone *mz = NULL;
/* create heap */
@@ -261,26 +290,9 @@ test_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova, int n_pages)
goto fail;
}
- /* check that we can get this memory from EAL now */
- for (i = 0; i < n_pages; i++) {
- const struct rte_memseg *ms;
- void *cur = RTE_PTR_ADD(addr, pgsz * i);
-
- ms = rte_mem_virt2memseg(cur, NULL);
- if (ms == NULL) {
- printf("%s():%i: Failed to retrieve memseg for external mem\n",
- __func__, __LINE__);
- goto fail;
- }
- if (ms->addr != cur) {
- printf("%s():%i: VA mismatch\n", __func__, __LINE__);
- goto fail;
- }
- if (ms->iova != iova[i]) {
- printf("%s():%i: IOVA mismatch\n", __func__, __LINE__);
- goto fail;
- }
- }
+ /* check if memory is accessible from EAL */
+ if (check_mem(addr, iova, pgsz, n_pages) < 0)
+ goto fail;
/* allocate - this now should succeed */
ptr = rte_malloc_socket("EXTMEM", 64, 0, socket_id);
@@ -379,8 +391,8 @@ test_external_mem(void)
iova[i] = tmp;
}
- ret = test_invalid_param(addr, len, pgsz, iova, n_pages);
- ret |= test_basic(addr, len, pgsz, iova, n_pages);
+ ret = test_malloc_invalid_param(addr, len, pgsz, iova, n_pages);
+ ret |= test_malloc_basic(addr, len, pgsz, iova, n_pages);
munmap(addr, len);
--
2.17.1
next prev parent reply other threads:[~2018-12-21 11:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 11:09 [dpdk-dev] [PATCH " Anatoly Burakov
2018-12-21 11:09 ` [dpdk-dev] [PATCH 2/4] test/extmem: extend autotest to test without IOVA table Anatoly Burakov
2018-12-21 11:09 ` [dpdk-dev] [PATCH 3/4] test/extmem: check if memseg list is external Anatoly Burakov
2018-12-21 11:09 ` [dpdk-dev] [PATCH 4/4] test/extmem: extend test to cover non-heap API Anatoly Burakov
2018-12-21 11:29 ` Anatoly Burakov [this message]
2018-12-21 11:29 ` [dpdk-dev] [PATCH v2 2/4] test/extmem: extend autotest to test without IOVA table Anatoly Burakov
2018-12-21 11:29 ` [dpdk-dev] [PATCH v2 3/4] test/extmem: check if memseg list is external Anatoly Burakov
2018-12-21 11:29 ` [dpdk-dev] [PATCH v2 4/4] test/extmem: extend test to cover non-heap API Anatoly Burakov
2018-12-21 15:19 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c822e5e21620d0fa4b2930d9e89bce44e80eac73.1545391716.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).