get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/57823/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 57823,
    "url": "http://patchwork.dpdk.org/api/patches/57823/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1566474836-30480-4-git-send-email-tallurix.chaitanya.babu@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1566474836-30480-4-git-send-email-tallurix.chaitanya.babu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1566474836-30480-4-git-send-email-tallurix.chaitanya.babu@intel.com",
    "date": "2019-08-22T11:53:56",
    "name": "[v2,3/3] app/test: add unit tests for eal vfio",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "6f1f47c8f66d9ba3e1c1177a77e2e30541506e28",
    "submitter": {
        "id": 1164,
        "url": "http://patchwork.dpdk.org/api/people/1164/?format=api",
        "name": "Chaitanya Babu, TalluriX",
        "email": "tallurix.chaitanya.babu@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1566474836-30480-4-git-send-email-tallurix.chaitanya.babu@intel.com/mbox/",
    "series": [
        {
            "id": 6109,
            "url": "http://patchwork.dpdk.org/api/series/6109/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=6109",
            "date": "2019-08-22T11:53:56",
            "name": null,
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/6109/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/57823/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/57823/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6D9E41BF90;\n\tThu, 22 Aug 2019 13:55:04 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id A1A481BF86\n\tfor <dev@dpdk.org>; Thu, 22 Aug 2019 13:55:00 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t22 Aug 2019 04:54:59 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 22 Aug 2019 04:54:58 -0700",
            "from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com\n\t[10.102.246.100])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tx7MBsv58022597; Thu, 22 Aug 2019 12:54:57 +0100",
            "from wgcvswdev001.ir.intel.com (localhost [127.0.0.1])\n\tby wgcvswdev001.ir.intel.com with ESMTP id x7MBsMm2030641;\n\tThu, 22 Aug 2019 12:54:22 +0100",
            "(from tchaitax@localhost)\n\tby wgcvswdev001.ir.intel.com with ? id x7MBsMqj030636;\n\tThu, 22 Aug 2019 12:54:22 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.64,416,1559545200\"; d=\"scan'208\";a=\"379309061\"",
        "From": "Chaitanya Babu Talluri <tallurix.chaitanya.babu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "reshma.pattan@intel.com, jananeex.m.parthasarathy@intel.com,\n\tanatoly.burakov@intel.com,\n\tChaitanya Babu Talluri <tallurix.chaitanya.babu@intel.com>",
        "Date": "Thu, 22 Aug 2019 12:53:56 +0100",
        "Message-Id": "<1566474836-30480-4-git-send-email-tallurix.chaitanya.babu@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<1566392575-7965-1-git-send-email-tallurix.chaitanya.babu@intel.com>",
        "References": "<1566392575-7965-1-git-send-email-tallurix.chaitanya.babu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 3/3] app/test: add unit tests for eal vfio",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Unit test cases are added for eal vfio library.\neal_vfio_autotest added to meson build file.\n\nSigned-off-by: Chaitanya Babu Talluri <tallurix.chaitanya.babu@intel.com>\n---\n app/test/Makefile        |   1 +\n app/test/meson.build     |   2 +\n app/test/test_eal_vfio.c | 728 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 731 insertions(+)\n create mode 100644 app/test/test_eal_vfio.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex 26ba6fe2b..9b9c78b4e 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -137,6 +137,7 @@ SRCS-y += test_cpuflags.c\n SRCS-y += test_mp_secondary.c\n SRCS-y += test_eal_flags.c\n SRCS-y += test_eal_fs.c\n+SRCS-y += test_eal_vfio.c\n SRCS-y += test_alarm.c\n SRCS-y += test_interrupts.c\n SRCS-y += test_version.c\ndiff --git a/app/test/meson.build b/app/test/meson.build\nindex ec40943bd..bd96ebb2b 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -36,6 +36,7 @@ test_sources = files('commands.c',\n \t'test_distributor_perf.c',\n \t'test_eal_flags.c',\n \t'test_eal_fs.c',\n+\t'test_eal_vfio.c',\n \t'test_efd.c',\n \t'test_efd_perf.c',\n \t'test_errno.c',\n@@ -175,6 +176,7 @@ fast_test_names = [\n         'eal_flags_file_prefix_autotest',\n         'eal_flags_misc_autotest',\n         'eal_fs_autotest',\n+        'eal_vfio_autotest',\n         'errno_autotest',\n         'event_ring_autotest',\n         'func_reentrancy_autotest',\ndiff --git a/app/test/test_eal_vfio.c b/app/test/test_eal_vfio.c\nnew file mode 100644\nindex 000000000..8995573df\n--- /dev/null\n+++ b/app/test/test_eal_vfio.c\n@@ -0,0 +1,728 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019 Intel Corporation\n+ */\n+\n+#include <stdio.h>\n+#include <string.h>\n+#include <stdint.h>\n+#include <errno.h>\n+#include <sys/mman.h>\n+#include <unistd.h>\n+#include <rte_vfio.h>\n+#include <rte_malloc.h>\n+#include <rte_eal_memconfig.h>\n+\n+#include \"test.h\"\n+\n+#if !defined(RTE_EXEC_ENV_LINUX) || !defined(RTE_EAL_VFIO)\n+static int\n+test_eal_vfio(void)\n+{\n+\tprintf(\"VFIO not supported, skipping test\\n\");\n+\treturn TEST_SKIPPED;\n+}\n+\n+#else\n+\n+#define PAGESIZE sysconf(_SC_PAGESIZE)\n+#define INVALID_CONTAINER_FD -5\n+#define THREE_PAGES 3\n+#define UNMAPPED_ADDR 0x1500\n+\n+uint64_t virtaddr_64;\n+const char *name = \"heap\";\n+size_t map_length;\n+int container_fds[RTE_MAX_VFIO_CONTAINERS];\n+\n+static int\n+check_get_mem(void *addr, rte_iova_t *iova)\n+{\n+\tconst struct rte_memseg_list *msl;\n+\tconst struct rte_memseg *ms;\n+\trte_iova_t expected_iova;\n+\n+\tmsl = rte_mem_virt2memseg_list(addr);\n+\tif (!msl->external) {\n+\t\tprintf(\"%s():%i: Memseg list is not marked as \"\n+\t\t\t\t\"external\\n\", __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tms = rte_mem_virt2memseg(addr, msl);\n+\tif (ms == NULL) {\n+\t\tprintf(\"%s():%i: Failed to retrieve memseg for \"\n+\t\t\t\t\"external mem\\n\", __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tif (ms->addr != addr) {\n+\t\tprintf(\"%s():%i: VA mismatch\\n\", __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\texpected_iova = (iova == NULL) ? RTE_BAD_IOVA : iova[0];\n+\tif (ms->iova != expected_iova) {\n+\t\tprintf(\"%s():%i: IOVA mismatch\\n\", __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+/* Initialize container fds */\n+static int\n+initialize_container_fds(void)\n+{\n+\tint i = 0;\n+\n+\tfor (i = 0; i < RTE_MAX_VFIO_CONTAINERS; i++)\n+\t\tcontainer_fds[i] = -1;\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* To test vfio container create */\n+static int\n+test_vfio_container_create(void)\n+{\n+\tint ret = 0, i = 0;\n+\n+\t/* check max containers limit */\n+\tfor (i = 1; i < RTE_MAX_VFIO_CONTAINERS; i++) {\n+\t\tcontainer_fds[i] = rte_vfio_container_create();\n+\t\tTEST_ASSERT(container_fds[i] >  0, \"Test to check \"\n+\t\t\t\t\"rte_vfio_container_create with max \"\n+\t\t\t\t\"containers limit: Failed\\n\");\n+\t}\n+\n+\t/* check rte_vfio_container_create when exceeds max containers limit */\n+\tret = rte_vfio_container_create();\n+\tTEST_ASSERT(ret == -1, \"Test to check \"\n+\t\t\t\"rte_vfio_container_create container \"\n+\t\t\t\"when exceeds limit: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* To test vfio container destroy */\n+static int\n+test_vfio_container_destroy(void)\n+{\n+\tint i = 0, ret = 0;\n+\n+\t/* check to destroy max container limit */\n+\tfor (i = 1; i < RTE_MAX_VFIO_CONTAINERS; i++) {\n+\t\tret = rte_vfio_container_destroy(container_fds[i]);\n+\t\tTEST_ASSERT(ret == 0, \"Test to check \"\n+\t\t\t\t\"rte_vfio_container_destroy: Failed\\n\");\n+\t\tcontainer_fds[i] = -1;\n+\t}\n+\n+\t/* check rte_vfio_container_destroy with valid but non existing value */\n+\tret = rte_vfio_container_destroy(0);\n+\tTEST_ASSERT(ret == -1, \"Test to check rte_vfio_container_destroy with \"\n+\t\t\t\"valid but non existing value: Failed\\n\");\n+\n+\t/* check rte_vfio_container_destroy with invalid value */\n+\tret = rte_vfio_container_destroy(-5);\n+\tTEST_ASSERT(ret == -1, \"Test to check rte_vfio_container_destroy \"\n+\t\t\t\"with invalid value: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* Test to bind a IOMMU group to a container*/\n+static int\n+test_rte_vfio_container_group_bind(void)\n+{\n+\tint ret = 0;\n+\n+\t/* Test case to bind with invalid container fd */\n+\tret = rte_vfio_container_group_bind(INVALID_CONTAINER_FD, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to bind a IOMMU group to a container \"\n+\t\t\t\"with invalid fd: Failed\\n\");\n+\n+\t/* Test case to bind with non-existing container fd */\n+\tret = rte_vfio_container_group_bind(0, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to bind a IOMMU group to a container \"\n+\t\t\t\"with non existing fd: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* Test to unbind a IOMMU group from a container*/\n+static int\n+test_rte_vfio_container_group_unbind(void)\n+{\n+\tint ret = 0;\n+\n+\t/* Test case to unbind container from invalid group*/\n+\tret = rte_vfio_container_group_unbind(INVALID_CONTAINER_FD, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to unbind a IOMMU group to a container \"\n+\t\t\t\"with invalid fd: Failed\\n\");\n+\n+\t/* Test case to unbind container from group*/\n+\tret = rte_vfio_container_group_unbind(0, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to unbind a IOMMU group to a container \"\n+\t\t\t\"with  non existing fd: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* Test to get IOMMU group number for a device*/\n+static int\n+test_rte_vfio_get_group_num(void)\n+{\n+\tint ret = 0, invalid_group_num = 0;\n+\n+\t/* Test case to get IOMMU group num from invalid group */\n+\tret = rte_vfio_get_group_num(NULL, NULL, &invalid_group_num);\n+\tTEST_ASSERT(ret == 0, \"Test to get IOMMU group num: Failed\\n\");\n+\n+\t/* Test case to get IOMMU group num from invalid device address and\n+\t * valid sysfs_base\n+\t */\n+\tret = rte_vfio_get_group_num(\"/sys/bus/pci/devices/\", NULL,\n+\t\t\t&invalid_group_num);\n+\tTEST_ASSERT(ret == 0, \"Test to get IOMMU group num: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* Test to perform DMA mapping for devices in a container */\n+static int\n+test_rte_vfio_container_dma_map(void)\n+{\n+\tint ret = 0, container_fd;\n+\n+\t/* Test case to map device for non-existing container_fd, with\n+\t * non-zero map_length\n+\t */\n+\tret = rte_vfio_container_dma_map(0, 0, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to check map device with invalid \"\n+\t\t\t\"container: Failed\\n\");\n+\n+\tcontainer_fd = rte_vfio_container_create();\n+\t/* Test case to map device for existing fd with no device attached and\n+\t * non-zero map_length\n+\t */\n+\tret = rte_vfio_container_dma_map(container_fd, 0, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to check  map device for existing fd \"\n+\t\t\t\"with no device attached and non-zero \"\n+\t\t\t\"map_length: Failed\\n\");\n+\n+\t/* Test to destroy for container fd */\n+\tret = rte_vfio_container_destroy(container_fd);\n+\tTEST_ASSERT(ret == 0, \"Container fd destroy failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* Test to perform DMA unmapping for devices in a container*/\n+static int\n+test_rte_vfio_container_dma_unmap(void)\n+{\n+\tint ret = 0, container_fd;\n+\n+\t/* Test case to unmap device for non-existing container_fd, with\n+\t * zero map_length\n+\t */\n+\tret = rte_vfio_container_dma_unmap(0, 0, 0, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to check map device with non-existing \"\n+\t\t\t\"container fd: Failed\\n\");\n+\n+\t/* Test case to unmap device for non-existing container_fd, with\n+\t * non-zero map_length\n+\t */\n+\tret = rte_vfio_container_dma_unmap(0, 0, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to check map device with non-existing \"\n+\t\t\t\"container fd: Failed\\n\");\n+\n+\tcontainer_fd = rte_vfio_container_create();\n+\t/* Test case to unmap device for existing fd with no device attached\n+\t * and with non-zero map_length\n+\t */\n+\tret = rte_vfio_container_dma_unmap(container_fd, 0, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to check map device with unmapped \"\n+\t\t\t\"container fd: Failed\\n\");\n+\n+\t/* Test case to unmap device for existing fd with no device attached\n+\t * and with zero map_length\n+\t */\n+\tret = rte_vfio_container_dma_unmap(container_fd, 0, 0, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to check map device with unmapped \"\n+\t\t\t\"container fd: Failed\\n\");\n+\n+\t/* Test to destroy for container fd */\n+\tret = rte_vfio_container_destroy(container_fd);\n+\tTEST_ASSERT(ret == 0, \"Container fd destroy failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/*Function to setup external memory */\n+static int\n+test_heap_mem_setup(size_t map_length, int n_pages)\n+{\n+\trte_iova_t iova[map_length / PAGESIZE];\n+\tvoid *addr;\n+\n+\taddr = mmap(NULL, map_length, PROT_WRITE | PROT_READ,\n+\t\t\tMAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n+\tif (addr == MAP_FAILED) {\n+\t\tprintf(\"%s():%i: Failed to create dummy memory area\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\trte_iova_t tmp = 0x100000000 + PAGESIZE;\n+\tiova[0] = tmp;\n+\n+\tif (rte_malloc_heap_create(name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to Create heap with valid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tif (rte_malloc_heap_memory_add(name, addr, map_length, iova, n_pages,\n+\t\t\t\tPAGESIZE) != 0) {\n+\t\tprintf(\"%s():%i: Failed to add memory to heap\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tif (check_get_mem(addr, iova) != 0) {\n+\t\tprintf(\"%s():%i: Failed to verify memory\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\n+\t\treturn -1;\n+\t}\n+\tvirtaddr_64 = (uint64_t)(uintptr_t)addr;\n+\n+\treturn 0;\n+}\n+\n+/* Function to free the external memory */\n+static void\n+test_heap_mem_free(void)\n+{\n+\tif (rte_malloc_heap_memory_remove(name, (void *)virtaddr_64,\n+\t\t\t\tmap_length) != 0) {\n+\t\tprintf(\"%s():%i: Failed to remove memory\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\treturn;\n+\t}\n+\trte_malloc_heap_destroy(name);\n+\n+\tmunmap((void *)virtaddr_64, map_length);\n+}\n+\n+/* Test to map memory region for use with VFIO*/\n+static int\n+test_rte_vfio_dma_map(void)\n+{\n+\tint ret = 0;\n+\n+\tconst int n_pages = 1;\n+\tmap_length = PAGESIZE;\n+\n+\ttest_heap_mem_setup(map_length, n_pages);\n+\n+\t/* Test case to map memory for VFIO with zero  vaddr, iova addr\n+\t * and map_length\n+\t */\n+\tret = rte_vfio_dma_map(0, 0, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with incorrect inputs: Failed\\n\");\n+\n+\t/* Test case to map memory for VFIO with zero vaddr, iova addr\n+\t * and valid map_length\n+\t */\n+\tret = rte_vfio_dma_map(0, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with valid map_length: Failed\\n\");\n+\n+\t/* Test case to map memory for VFIO with valid iova addr, unmapped\n+\t * vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_map(1000000, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"unmapped virtual address: Failed\\n\");\n+\n+\t/* Test case to map memory for VFIO with valid iova addr, mapped\n+\t * vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == 0, \"Test to map devices within default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to check already mapped virtual address */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to check start virtual address + length range overlaps */\n+\tret = rte_vfio_dma_map((virtaddr_64 + UNMAPPED_ADDR), 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with overlapping virtual address: Failed\\n\");\n+\n+\t/* Test case to check start virtual address before\n+\t * existing map, overlaps\n+\t */\n+\tret = rte_vfio_dma_map((virtaddr_64 - UNMAPPED_ADDR), 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with start virtual address \"\n+\t\t\t\"before existing map, overlaps: Failed\\n\");\n+\n+\t/* Test case to check invalid map length */\n+\tret = rte_vfio_dma_map((virtaddr_64 - UNMAPPED_ADDR), 0, 500);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with invalid map length: Failed\\n\");\n+\n+\t/* Test case to check already mapped iova overlaps */\n+\tret = rte_vfio_dma_map((virtaddr_64 + 8192), 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with already mapped iova overlaps: Failed\\n\");\n+\n+\t/* Test case to check start iova + length range overlaps */\n+\tret = rte_vfio_dma_map((virtaddr_64 + 8192), (0 + UNMAPPED_ADDR),\n+\t\t\tmap_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with start iova + length range overlaps: Failed\\n\");\n+\n+\t/* Test case to check invalid iova */\n+\tret = rte_vfio_dma_map((virtaddr_64 + 8192), (0 + 5000), map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with invalid iova: Failed\\n\");\n+\n+\t/* Test case to check invalid map length */\n+\tret = rte_vfio_dma_map((virtaddr_64 + 8192), (0 + UNMAPPED_ADDR), 100);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with invalid map length: Failed\\n\");\n+\n+\t/* Test case to map memory for VFIO with invalid vaddr, valid iova addr\n+\t * and valid map_length\n+\t */\n+\tuint64_t invalid_addr = virtaddr_64 + 1;\n+\tret = rte_vfio_dma_map(invalid_addr, virtaddr_64, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with mapped invalid virtual address: Failed\\n\");\n+\n+\t/* Test case to map memory for VFIO with invalid iova addr, valid vaddr\n+\t * and valid map_length\n+\t */\n+\tret = rte_vfio_dma_map(virtaddr_64, UNMAPPED_ADDR, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map devices within default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"invalid iova address: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with valid iova,\n+\t * mapped vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/* Test to unmap memory region for use with VFIO*/\n+static int\n+test_rte_vfio_dma_unmap(void)\n+{\n+\tint ret = 0;\n+\n+\tconst int n_pages = 1;\n+\tmap_length = PAGESIZE;\n+\n+\ttest_heap_mem_setup(map_length, n_pages);\n+\n+\t/* Test case to unmap memory region from VFIO with zero vaddr,\n+\t * iova addr and map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(0, 0, 0);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap devices in default container \"\n+\t\t\t\"with incorrect input: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with zero vaddr,\n+\t * iova addr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(0, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with zero iova addr,\n+\t * unmapped vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length and unmapped addr: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with unmapped vaddr, iova\n+\t * and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(virtaddr_64, virtaddr_64, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"unmapped addr, iova: Failed\\n\");\n+\n+\t/* Test case to map memory region from VFIO with valid iova,\n+\t * mapped vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with mapped invalid vaddr,\n+\t * valid IOVA and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap((virtaddr_64 + 1), 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length and mapped \"\n+\t\t\t\"invalid virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with mapped\n+\t * valid iova addr, vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap devices in default container \"\n+\t\t\t \"with valid map_length and mapped \"\n+\t\t\t \"valid virtual address: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_rte_vfio_dma_map_overlaps(void)\n+{\n+\tint ret = 0;\n+\tconst int n_pages = THREE_PAGES;\n+\tmap_length = PAGESIZE * THREE_PAGES;\n+\n+\ttest_heap_mem_setup(map_length, n_pages);\n+\n+\t/* Test case to map 1st page */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to map device in default container \"\n+\t\t\t\"with valid address:Failed\\n\");\n+\n+\t/* Test case to map same start virtual address and\n+\t * extend beyond end virtual address\n+\t */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, (PAGESIZE * 2));\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with same start virtual address and extend beyond end \"\n+\t\t\t\"virtual address: Failed\\n\");\n+\n+\t/* Test case to map same start virtual address and same end address*/\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, PAGESIZE);\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with same start virtual address and \"\n+\t\t\t\"same end address: Failed\\n\");\n+\n+\t/* Test case to unmap 1st page */\n+\tret = rte_vfio_dma_unmap(virtaddr_64, 0, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap device in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to map different virtual address */\n+\tret = rte_vfio_dma_map((virtaddr_64 + PAGESIZE), (0 + PAGESIZE),\n+\t\t\t(PAGESIZE * 2));\n+\tTEST_ASSERT(ret == 0, \"Test to map device in default container \"\n+\t\t\t\"with different virtual address: Failed\\n\");\n+\n+\t/* Test case to map different start virtual address and\n+\t * ends with same address\n+\t */\n+\tret = rte_vfio_dma_map((virtaddr_64 + (PAGESIZE * 2)),\n+\t\t\t(0 + (PAGESIZE * 2)), PAGESIZE);\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with different start virtual address and \"\n+\t\t\t\"ends with same address: Failed\\n\");\n+\n+\t/* Test case to map three pages */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with overlapping virtual address range: Failed\\n\");\n+\n+\t/* Test case to map middle overlapping virtual address */\n+\tret = rte_vfio_dma_map((virtaddr_64 + PAGESIZE), (0 + PAGESIZE),\n+\t\t\tPAGESIZE);\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with overlapping virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap 1st page */\n+\tret = rte_vfio_dma_unmap(virtaddr_64, 0, PAGESIZE);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap 1st page: Failed\\n\");\n+\n+\t/* Test case to map 1st and 2nd page overlaps */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, (PAGESIZE * 2));\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with 1st and 2nd page overlaps: Failed\\n\");\n+\n+\t/* Test case to map 3rd and 4th pages */\n+\tret = rte_vfio_dma_map((virtaddr_64 + (PAGESIZE * 2)),\n+\t\t\t(0 + (PAGESIZE * 2)), (PAGESIZE * 2));\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with 3rd and 4th pages: Failed\\n\");\n+\n+\t/* Test case to unmap 3rd page */\n+\tret = rte_vfio_dma_unmap((virtaddr_64 + (PAGESIZE * 2)),\n+\t\t\t(0 + (PAGESIZE * 2)), PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap 3rd page: Failed\\n\");\n+\n+\t/* Test case to map 1st page with total length\n+\t * that overlaps middle page\n+\t */\n+\tret = rte_vfio_dma_map(virtaddr_64, 0, map_length);\n+\tTEST_ASSERT(ret == -1, \"Test to map device in default container \"\n+\t\t\t\"with 1st page with total length \"\n+\t\t\t\"that overlaps middle page: Failed\\n\");\n+\n+\t/* Test case to unmap 2nd page  */\n+\tret = rte_vfio_dma_unmap((virtaddr_64 + PAGESIZE), (0 + PAGESIZE),\n+\t\t\tPAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap 2nd page: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/*allocate three pages */\n+static int\n+test_rte_vfio_dma_map_threepages(void)\n+{\n+\tint ret = 0;\n+\n+\tconst int n_pages = THREE_PAGES;\n+\tmap_length = PAGESIZE * THREE_PAGES;\n+\tuint64_t page1_va, page2_va, page3_va;\n+\trte_iova_t page1_iova, page2_iova, page3_iova;\n+\n+\tpage1_va = virtaddr_64;\n+\tpage2_va = virtaddr_64 + PAGESIZE;\n+\tpage3_va = virtaddr_64 + (PAGESIZE * 2);\n+\n+\tpage1_iova = 0;\n+\tpage2_iova = 0 + PAGESIZE;\n+\tpage3_iova = 0 + (PAGESIZE * 2);\n+\n+\ttest_heap_mem_setup(map_length, n_pages);\n+\n+\t/* Test case to map three pages */\n+\tret = rte_vfio_dma_map(page1_va, page1_iova, map_length);\n+\tTEST_ASSERT(ret == 0, \"Test to map device in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap 1st page */\n+\tret = rte_vfio_dma_unmap(page1_va, page1_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap device in default container \"\n+\t\t\t\"with valid 1st page map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to map 1st page */\n+\tret = rte_vfio_dma_map(page1_va, page1_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to map device in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped valid virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap 2nd page */\n+\tret = rte_vfio_dma_unmap(page2_va, page2_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap device in default container \"\n+\t\t\t\"with valid map_length and mapped \"\n+\t\t\t\"valid 2nd page virtual address: Failed\\n\");\n+\n+\t/* Test case to map 2nd page */\n+\tret = rte_vfio_dma_map(page2_va, page2_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to map device in default container \"\n+\t\t\t\"with valid map_length and mapped \"\n+\t\t\t\"valid 2nd page virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap 3rd page */\n+\tret = rte_vfio_dma_unmap(page3_va, page3_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap device in default container \"\n+\t\t\t\"with valid map_length and mapped \"\n+\t\t\t\"valid 3rd page virtual address: Failed\\n\");\n+\n+\t/* Test case to map 3rd page */\n+\tret = rte_vfio_dma_map(page3_va, page3_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == 0, \"Test to map device in default container \"\n+\t\t\t\"with valid map_length and \"\n+\t\t\t\"mapped 3rd page valid virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap 1st page, but used IOVA address of 2nd page */\n+\tret = rte_vfio_dma_unmap(page1_va, page2_iova, PAGESIZE);\n+\tTEST_ASSERT(ret == -1, \"Test to unmap devices in default container \"\n+\t\t\t\"with valid map_length and mapped \"\n+\t\t\t\"valid virtual address: Failed\\n\");\n+\n+\t/* Test case to unmap memory region from VFIO with mapped\n+\t * valid iova addr, vaddr and valid map_length\n+\t */\n+\tret = rte_vfio_dma_unmap(page1_va, page1_iova, map_length);\n+\tTEST_ASSERT(ret == 0, \"Test to unmap devices in default container \"\n+\t\t\t \"with valid map_length and mapped \"\n+\t\t\t \"valid virtual address: Failed\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static struct\n+unit_test_suite eal_vfio_testsuite  = {\n+\t.suite_name = \"EAL VFIO Unit Test Suite\",\n+\t.setup = initialize_container_fds,\n+\t.teardown = NULL,\n+\t.unit_test_cases = {\n+\t\t/* Test Case 1: To check vfio container create test cases */\n+\t\tTEST_CASE(test_vfio_container_create),\n+\n+\t\t/* Test Case 2: To check vfio container destroy */\n+\t\tTEST_CASE(test_vfio_container_destroy),\n+\n+\t\t/* Test Case 3: To  bind a IOMMU group to a container.*/\n+\t\tTEST_CASE(test_rte_vfio_container_group_bind),\n+\n+\t\t/* Test Case 4: To get IOMMU group number for a device*/\n+\t\tTEST_CASE(test_rte_vfio_get_group_num),\n+\n+\t\t/* Test Case 5: To unbind a IOMMU group to a container.*/\n+\t\tTEST_CASE(test_rte_vfio_container_group_unbind),\n+\n+\t\t/* Test Case 6: To perform DMA mapping for devices in default\n+\t\t * container\n+\t\t */\n+\t\tTEST_CASE_ST(NULL, test_heap_mem_free, test_rte_vfio_dma_map),\n+\n+\t\t/* Test Case 7: To perform DMA unmapping for devices in default\n+\t\t * container\n+\t\t */\n+\t\tTEST_CASE_ST(NULL, test_heap_mem_free,\n+\t\t\t\ttest_rte_vfio_dma_unmap),\n+\n+\t\t/* Test Case 8: To perform map devices in specific container */\n+\t\tTEST_CASE(test_rte_vfio_container_dma_map),\n+\n+\t\t/* Test Case 9: To perform unmap devices in specific container\n+\t\t */\n+\t\tTEST_CASE(test_rte_vfio_container_dma_unmap),\n+\n+\t\t/* Test Case 10: To perform three pages */\n+\t\tTEST_CASE_ST(NULL, test_heap_mem_free,\n+\t\t\t\ttest_rte_vfio_dma_map_threepages),\n+\n+\t\t/* Test Case 11: To check DMA overlaps */\n+\t\tTEST_CASE_ST(NULL, test_heap_mem_free,\n+\t\t\t\ttest_rte_vfio_dma_map_overlaps),\n+\n+\t\tTEST_CASES_END()\n+\t}\n+};\n+\n+static int\n+test_eal_vfio(void)\n+{\n+\treturn unit_test_suite_runner(&eal_vfio_testsuite);\n+}\n+\n+#endif\n+\n+REGISTER_TEST_COMMAND(eal_vfio_autotest, test_eal_vfio);\n",
    "prefixes": [
        "v2",
        "3/3"
    ]
}